#ifndef _GEOMSPHERE_
#define _GEOMSPHERE_

#include "GeomObject.h"

class GeomSphere: public GeomObject{
protected:
	double mRadius;
	bool mFirstDraw;
public:
	// Constructor
	GeomSphere(double _radius): mRadius(_radius){
		mType=SPHERE;
		mFirstDraw = true;
	}
	GeomSphere(Vec3d _center, double _radius);

	bool isInside(Vec3d _pt){
		Vec3d _localPt = xform(getInvWorldTransform(), _pt);
		return sqrlen((_pt)/(mRadius))<1;
	}
	// Get signed distance to inPoint
	inline double getSignedDist(const Vec3d &inPoint){
		Vec3d _localPt = xform(getInvWorldTransform(), inPoint);
		return len(_localPt) - mRadius;
	}
	double getVolume(){
		return mRadius*mRadius*mRadius;	//	a*b*c
	}
	void setExtent(Vec3d _d){mRadius=_d[0]/2;}

	void draw(Vec4d _col=Vec4d(vl_1), bool _default=true);

	inline double getRadius(){ return mRadius; }
	inline Vec3d getCenter(){
		return Vec3d(mTransform[0][3], mTransform[1][3], mTransform[2][3]);
	}

	// Transform a plane by the inverse of inInverseMatrix
	GeomObject* getObjApplyInvTransform(const Mat4d &_mat);

};

#endif
